package com.lingnan.tijian.config;

import com.lingnan.tijian.interceptor.JWTInterceptor;
import com.lingnan.tijian.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class TijianWebInterceptorConfig implements WebMvcConfigurer {



    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/**").order(10) // 拦截所有请求路径
        .excludePathPatterns("/login", "/register"); // 排除某些路径

        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**") // 拦截所有请求路径
        .excludePathPatterns("/login", "/register").order(20); // 排除某些路径
    }


}